package com.lin.activity;

import java.util.ArrayList;

import com.lin.utils.Session;
import com.lin.utils.Session.ResultReceiver;
import com.lin.views.ListViewForGuanzhu;
import com.lin.views.ListViewForSuperFriends;
import com.sidingbar2.view.MySideBar;
import com.sidingbar2.view.MySideBar.OnTouchingLetterChangedListener;
import com.yunfeng.supercall.R;
import com.yunfeng.supercall.activity.BaseActivity;
import com.yunfeng.supercall.bean.SuperFriendsBean;

import android.app.Activity;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.view.View;

public class MyFansActivity extends Activity implements OnTouchingLetterChangedListener{
	ListViewForGuanzhu mListview;
	Session mSession;
	private MySideBar sideBar;
	ArrayList<SuperFriendsBean> mArrayList;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_guanzhu_and_fans);
		mSession = Session.getSession();
		mSession.init(getApplicationContext(), true);
		mSession.getGuanzhuList(getApplicationContext(), 0, BaseActivity.getUser(getApplicationContext()).getUserid(), new ResultReceiver<ArrayList<SuperFriendsBean>>(){

			@Override
			public void onResult(boolean last, ArrayList<SuperFriendsBean> data) {
				// TODO Auto-generated method stub
				if(data == null) return;
				int position = 0;
				mArrayList = data;
				//				String nickName;
				//				String pingyin = "";
				//				String firstSpell = "#";
				//				SuperFriendsBean superFriendBean = new SuperFriendsBean();
				//				superFriendBean.setNick_name(firstSpell);
				//				data.add(position, superFriendBean);
				//				int size = data.size();
				//				position ++ ;
				//				while(position < size) {
				//					SuperFriendsBean superFriendsBean = data.get(position);
				//					nickName = superFriendsBean.getNick_name();
				//					if(nickName != null) {
				//						pingyin = PinyinUtils.converterToFirstSpell(nickName);
				//					}
				//					String secondTime = new String(pingyin.substring(0, 1)).trim();
				//					String firstTime = new String(firstSpell.trim());
				//					Character firstChar = firstTime.charAt(0) ;
				//					Character secondChar = secondTime.charAt(0) ;
				//					
				//					if(firstChar.compareTo(secondChar) != 0)
				//						firstSpell = secondTime;
				//						if (pingyin.length() > 0) {
				//							superFriendBean = new SuperFriendsBean();
				//							superFriendBean.setNick_name(pingyin.substring(0, 1));
				//							data.add(position, superFriendBean);
				//							size = data.size();
				//							position ++ ;
				//						}
				//					position ++ ;
				//				}
				if(data != null) {
					mListview.setDataList(data);
					mArrayList = data;
				}
			}

		});

		sideBar = (MySideBar) findViewById(R.id.myView);
		mListview = (ListViewForGuanzhu) findViewById(R.id.listview);
		sideBar.setOnTouchingLetterChangedListener(this);

	}

	@Override
	public void onTouchingLetterChanged(String s) {
		// TODO Auto-generated method stub
		
	}
	
	
	
}